package com.ourhealth.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.ourhealth.constant.MessageConstant;
import com.ourhealth.entity.Result;
import com.ourhealth.pojo.Setmeal;
import com.ourhealth.service.SetMealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("setMealApp")
public class SetMealController {
    @Reference
    private SetMealService setMealService;
    @RequestMapping("getSetMeal")
    public Result getSetMeal(){
        List<Setmeal> setmeals = null;
        try {
            setmeals = setMealService.findAll();
        } catch (Exception e) {
            return new Result(false, MessageConstant.QUERY_SETMEAL_FAIL);
        }
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setmeals);
    }

    @RequestMapping("findById")
    public Result findById(Integer id){
       Setmeal setmeal = null;
        try {
            setmeal = setMealService.findByIdUp(id);
        } catch (Exception e) {
            return new Result(false, MessageConstant.QUERY_SETMEAL_FAIL);
        }
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
    }
}
